import {
    getCouponList,
    getCouponDetails,
    getSurpriseTicketList,
    getSurpriseTicketDetails,
    getFullDiscountActivity,
    getAvailableProductV2,
    getFullDiscountActivityDetails,
    getListFlashWithTimeLimit,
    getDetailFlashAndGoods,
    getListNewUserGift,
    getDetailNewUserGift,
    getPromotionListFlash,
    getPromotionDetails,
    getFullDiscountOnePriductActivity
} from "@Api/productApi"
import { message, Modal } from "@bytedance/mona-ui";
import getGoodsQWorkTEXT from 'data-text:./prodectWork.js'
import { store } from "~store"
import { setIsInit } from '~store/controller/jinritemaiDecrypt'

const workStr = getGoodsQWorkTEXT;
const workBlob = new Blob([workStr], { type: 'text/javascript;charset=utf-8' });
const workBlobUrl = URL.createObjectURL(workBlob);
/**
 * 
 * @param pra { page: number, size: number, campaign_status: number }
 * @returns 获取参加限时限量购的链接 包括活动信息 商品sku信息
 */
export function pollutionFunc(pra: { page: number, size: number, campaign_status: number }) {
    let GoodsDataCache = []
    let goodsResolve: any = null
    return getFlashWithGoodsData(pra)
    function getFlashWithGoodsData(data: any) {
        return new Promise((resolve, reject) => {
            goodsResolve = goodsResolve || resolve
            getListFlashWithTimeLimit(data).then((res: any) => {
                const getDetailData = res?.total > 0 && res.data.flash_list
                    .map((item: any) => {
                        return getDetailFlashAndGoods({ activity_id: item.merchant_activity_id })
                    }) || goodsResolve([])
                getDetailData && getDetailData.length && Promise.all(getDetailData).then(goodsitem => {
                    // 过滤去重
                    GoodsDataCache.push(...goodsitem.map(item => item.data))
                    if (res?.total > (data.page * data.size)) {
                        data.page++
                        getFlashWithGoodsData(data)
                    } else {
                        goodsResolve(GoodsDataCache)
                    }
                })
            }).catch(err => {
                console.log(err)
            })
        })
    }
}
/**
 * 
 * @param pra  { page: number, pageSize: number, activity_status: string }
 * @returns 获取有效的满减活动列表
 */
export function getDiscountActivityAcyucn(pra: { page: number, pageSize: number, activity_status: string }) {
    let GoodsDataCache: any = []
    let goodsResolve: any = null
    return getFlashWithGoodsData(pra)
    function getFlashWithGoodsData(data: any) {
        return new Promise((resolve, reject) => {
            goodsResolve = goodsResolve || resolve
            getFullDiscountActivity(data).then((res: any) => {
                const getDetailData = res.data?.total > 0 && res.data.data
                    .map((item: any) => {
                        return getFullDiscountActivityDetails({ activity_id: item.activity_id })
                    }) || goodsResolve([])
                getDetailData && getDetailData.length && Promise.all(getDetailData).then((goodsitem: any) => {
                    // 过滤去重
                    GoodsDataCache.push(...goodsitem.map((item: any) => item.data))
                    if (res.data?.total > (data.page * data.pageSize)) {
                        data.page++
                        getFlashWithGoodsData(data)
                    } else {
                        const manjianActivityData: any = []
                        GoodsDataCache.forEach((acdt: any) => {
                            acdt && acdt.full_discount_activity && acdt.full_discount_activity.activity_products
                                .forEach(fda => {
                                    for (let keyins in acdt.full_discount_activity) {
                                        if (keyins !== 'activity_products') fda[keyins] = acdt.full_discount_activity[keyins]
                                    }
                                    manjianActivityData.push(fda)
                                })
                        })
                        goodsResolve(manjianActivityData)
                    }
                })
            }).catch(err => {
                console.log(err)
            })
        })
    }
}

/**
 * 
 * @param pra  { page: number, pageSize: number, activity_status: string }
 * @returns 获取有效的满减同品多件活动列表
 */
export function getDiscountActivityOnePrdAcyucn(pra: { page: number, pageSize: number, activity_status: string }) {
    let getallData: any = []
    let goodsResolve: any = null
    return getFlashWithGoodsData(pra)
    function getFlashWithGoodsData(data: any) {
        return new Promise((resolve, reject) => {
            goodsResolve = goodsResolve || resolve
            getFullDiscountOnePriductActivity(data).then((res: any) => {
                if (res.code) {
                    const { __token, msToken, inInit } = store.getState().jinritemaiDecrypt
                    if (inInit) {
                        setTimeout(_ => {
                            store.dispatch(setIsInit(false))
                        }, 1000)
                        return
                    }
                    let contents = ``

                    if(res.code == '-10001') {
                        contents = `\n请使用主账户，子账户管理 ==> 修改权限 ==> 勾选运营权限`
                    }
                    Modal.confirm({
                        title: '策略转换提示',
                        content: res.msg + contents,
                        icon: null,
                        okText: '知道了',
                        showCancel: false,
                        onOk: () => {
                            goodsResolve({
                                syserr:1
                            })
                        }
                    })
                    return
                }
                while ((pra.pageSize * (pra.page)) < res.data.total) {
                    pra.page++
                    getallData.push(getFullDiscountOnePriductActivity(pra))
                }
                Promise.all(getallData).then(resit => {

                    const datas: any = res.data.data || []

                    resit.forEach(resdata => {
                        if (!resdata || !resdata.data || !resdata.data.data) return
                        datas.push(...resdata.data.data)
                    })
                    goodsResolve(datas.map(itembot => {
                        itembot.product_id = itembot.activity_product.product_id
                        return itembot
                    }))
                })
            }).catch(err => {
                console.log(err)
            })
        })
    }
}

/**
 * 
 * @param id 商品ID
 * @param ActivetiGoodsList 获取参加限时限量购的商品列表
 * @returns 返回该商品的活动信息
 */
export function getActivetiGoodsData(id: string, ActivetiGoodsList: any) {

    const getFindInfoter = ActivetiGoodsList.find((item: any) => item.product_id === id)
    if (!getFindInfoter) {
        return {
            showstatus: false,
        }
    }
    const outerCopy = JSON.parse(JSON.stringify(getFindInfoter))
    outerCopy.showstatus = true
    outerCopy.minPrice = Math.min(...getFindInfoter.promotion_skus.map(res => {
        return res.price
    }))
    outerCopy.originalPrice = getFindInfoter.min_price === getFindInfoter.max_price ? `￥${(getFindInfoter.min_price / 100).toFixed(2)}` : `￥${(getFindInfoter.min_price / 100).toFixed(2)}~￥${(getFindInfoter.max_price / 100).toFixed(2)}`
    outerCopy.nowPrice = getNowPrice(getFindInfoter)
    outerCopy.shopSvalue = ''
    outerCopy.tagname = getTagnameFun(getFindInfoter.shop_stype)
    return outerCopy
    // return {
    //     minPrice: getFindInfoter ? getFindInfoter.min_price : '',
    //     showstatus: getFindInfoter ? 1 : 2, // 是否有活动
    //     getFindInfoter: getFindInfoter || '',
    //     originalPrice: getFindInfoter ? getFindInfoter.min_price === getFindInfoter.max_price ? `￥${(getFindInfoter.min_price / 100).toFixed(2)}` : `￥${(getFindInfoter.min_price / 100).toFixed(2)}-￥${(getFindInfoter.max_price / 100).toFixed(2)}` : null,
    //     nowPrice: getFindInfoter ? getNowPrice(getFindInfoter) : null,
    //     tagname: getFindInfoter ? getTagnameFun(getFindInfoter.shop_stype) : null,
    // }
    function getTagnameFun(shop_stype: number) {
        // 1：一口价， 2：直降价 ，3：打折
        let tagname: string = ''
        switch (shop_stype) {
            case 1:
                tagname = '一口价'
                break;
            case 2:
                tagname = '直降价'
                break;
            case 3:
                tagname = '打折'
                outerCopy.shopSvalue = getShopSvalue(getFindInfoter)
                break;
            default:
                break;
        }
        return tagname
    }
    function getShopSvalue(data: any) {
        // 获取则扣情况
        const minPrice = Math.min(...data.promotion_skus.map(res => {
            return res.shop_svalue
        })); // 获取最小值
        const maxPrice = Math.max(...data.promotion_skus.map(res => {
            return res.shop_svalue
        }));
        return minPrice === maxPrice ? `${(minPrice / 10).toFixed(1)}` : `${(minPrice / 10).toFixed(1)}~${(maxPrice / 10).toFixed(1)}`
    }
    function getNowPrice(data: any) {
        const minPrice = Math.min(...data.promotion_skus.map(res => {
            return res.price
        })); // 获取最小值
        const maxPrice = Math.max(...data.promotion_skus.map(res => {
            return res.price
        }));
        return minPrice === maxPrice ? `￥${(minPrice / 100).toFixed(2)}` : `￥${(minPrice / 100).toFixed(2)}~￥${(maxPrice / 100).toFixed(2)}`
    }
}
/**
 * 
 * @param id 商品ID
 * @param getDiscountActivityData 满减活动商品列表
 * @returns 返回该商品的满减活动信息
 */
export function getDiscountActivityFarmet(id: string, getDiscountActivityData: any) {
    const getFindInfoter = getDiscountActivityData && getDiscountActivityData.find(res => res.product_id === id)
    if (!getFindInfoter) return {
        showstatus: false
    }
    const getFindInfoterData = JSON.parse(JSON.stringify(getFindInfoter))
    getFindInfoterData.showstatus = true
    getFindInfoterData.discount_type_string = []
    getFindInfoterData.discounts.forEach((res: any) => {
        getFindInfoterData.discount_type_string.push(setTypeString(res))
    })
    return getFindInfoterData
    function setTypeString(data: any) {
        const { discount_type, condition_type, condition_value, discount } = data
        if (condition_type === 1) {
            if (discount_type === 1) {
                return {
                    title: `满${condition_value}件${(discount / 10).toFixed(1) * 1}折`,
                    func: '*',
                    out_type: 'jian',
                    condition_value,
                    discount: (discount / 10).toFixed(1),
                    condition_type,
                    discount_type,
                    condition_value_ol: condition_value,
                    discount_ol: discount
                }
            } else if (discount_type === 3) {
                return {
                    title: `满${condition_value}件减${(discount / 100).toFixed(2) * 1}`,
                    func: '-',
                    out_type: 'jian',
                    condition_value,
                    discount: (discount / 100).toFixed(2),
                    condition_type,
                    discount_type,
                    condition_value_ol: condition_value,
                    discount_ol: discount
                }
            }
        } else if (condition_type === 2) {
            if (discount_type === 1) {
                return {
                    title: `满${(condition_value / 100).toFixed(2) * 1}元${(discount / 10).toFixed(1) * 1}折`,
                    func: '*',
                    out_type: 'yuan',
                    condition_value: (condition_value / 100).toFixed(2),
                    discount: (discount / 10).toFixed(1),
                    condition_type,
                    discount_type,
                    condition_value_ol: condition_value,
                    discount_ol: discount
                }
            } else if (discount_type === 3) {
                return {
                    title: `满${(condition_value / 100).toFixed(2) * 1}减${(discount / 100).toFixed(2) * 1}`,
                    func: '-',
                    out_type: 'yuan',
                    condition_value: (condition_value / 100).toFixed(2),
                    discount: (discount / 100).toFixed(2),
                    condition_type,
                    discount_type,
                    condition_value_ol: condition_value,
                    discount_ol: discount
                }
            }
        }
    }
}
/**
 * 
 * @param pra { page: number, pageSize: number, apply_status: string }
 * @returns 批量获取参加新人礼金活动商品列表
 */
export function getListNewUserGiftFarmet(pra: { page: number, pageSize: number, apply_status: number }) {
    let GoodsDataCache: any = []
    let goodsResolve: any = null
    return getFlashWithGoodsData(pra)
    function getFlashWithGoodsData(data: any) {
        return new Promise((resolve, reject) => {
            goodsResolve = goodsResolve || resolve
            getListNewUserGift(data).then((res: any) => {
                const getDetailData = res.data?.total > 0 && res.data.records
                    .map((item: any) => {
                        return getDetailNewUserGift({ apply_id: item.apply_id })
                    }) || goodsResolve([])
                getDetailData && getDetailData.length && Promise.all(getDetailData).then(goodsitem => {
                    // console.log('goodsitem', goodsitem)
                    // 过滤去重
                    GoodsDataCache.push(...goodsitem.map(item => item.data))
                    if (res.data?.total > (data.page * data.pageSize)) {
                        data.page++
                        getFlashWithGoodsData(data)
                    } else {
                        const manjianActivityData: any = []
                        // console.log('GoodsDataCache', GoodsDataCache)
                        GoodsDataCache.forEach(acdt => {
                            acdt && acdt.apply_products && acdt.apply_products.forEach(aply => {
                                aply.basic_rule = acdt.basic_rule
                                manjianActivityData.push(aply)
                            })
                        })
                        goodsResolve(manjianActivityData)
                    }
                })
            }).catch(err => {
                console.log(err)
            })
        })
    }
}

export function getNewUserGiftFarme(id: string, getDetailNewUserGiftAllDataState: any) {
    const getFindInfoter = getDetailNewUserGiftAllDataState.find(res => res.product_id === id)
    if (!getFindInfoter) {
        return {
            showstatus: false
        }
    }
    // console.log('getFindInfoter', getFindInfoter)
    const retenFindDataJSON = JSON.parse(JSON.stringify(getFindInfoter))
    retenFindDataJSON.showstatus = true
    const count = retenFindDataJSON.allowance_info.coupon_value || retenFindDataJSON.allowance_info.max_shop_deduction_credit
    retenFindDataJSON.shownumcontern = {
        title: '首单立减',
        num: (count / 100).toFixed(2),
        unit: `${(count / 100).toFixed(2)}元`
    }
    return retenFindDataJSON
}

/**
 * @param pra { page: number, pageSize: number}
 * @returns 批量获取优惠券参加的商品列表
 */

// console.log('Worker', Worker)
let getGoodsQWorkFuns
export function getCouponListFarmet(data: { page: number, pageSize: number }) {
    return new Promise((resolve, reject) => {
        if (getGoodsQWorkFuns) getGoodsQWorkFuns.terminate()
        if (typeof Worker === 'undefined') {
            message.error('当前浏览器版本过低，部分功能无法正常使用，请升级浏览器后使用')
            throw new Error('当前浏览器不支持Worker')
        }
        getGoodsQWorkFuns = new Worker(workBlobUrl)
        getGoodsQWorkFuns.postMessage({
            type: 'getCoupon',
            data
        })
        getGoodsQWorkFuns.onmessage = function (e: any) {
            if (e.data.type === 'putCoupon') {
                resolve(e.data.data)
                if (getGoodsQWorkFuns) getGoodsQWorkFuns.terminate()
            }
        }
    })
}
/**
 * 
 * @param pra 
 * @returns 获取惊喜券列表 商品信息
 */
export function getSurpriseTicketLisFarmet(pra: { page: number, pageSize: number }) {
    let GoodsDataCache = []
    let goodsResolve: any = null
    return getFlashWithGoodsData(pra)
    function getFlashWithGoodsData(data: any) {
        return new Promise((resolve, reject) => {
            goodsResolve = goodsResolve || resolve
            getSurpriseTicketList(data).then((res: any) => {
                const getDetailData = res.data?.total > 0 && res.data.instances
                    .map((item: any) => {
                        return getSurpriseTicketDetails({ activity_id: item.activity_id })
                    }) || goodsResolve([])
                getDetailData && getDetailData.length && Promise.all(getDetailData).then(goodsitem => {
                    // 过滤去重
                    GoodsDataCache.push(...goodsitem.map(item => item.data))
                    if (res.data?.total > (data.page * data.pageSize)) {
                        data.page++
                        getFlashWithGoodsData(data)
                    } else {
                        const manjianActivityData = []
                        GoodsDataCache && GoodsDataCache.forEach(acdt => {
                            acdt && acdt.coupon_infos && acdt.coupon_infos.length && acdt.coupon_infos.forEach(tbs => {
                                // 指定商品信息
                                const addinfojsons = tbs
                                for (let key in acdt) {
                                    if (key != 'coupon_infos') {
                                        addinfojsons[key] = acdt[key]
                                    }
                                }
                                manjianActivityData.push(addinfojsons)
                            })
                        })
                        goodsResolve(manjianActivityData)
                    }
                })
            }).catch(err => {
                console.log(err)
            })
        })
    }
}
/**
 * 
 * @param id 
 * @param getSurpriseTicketLisAllDataState 
 * @returns 筛选惊喜券
 */
export function getSurpriseTicketDataFarmet(id: number, getSurpriseTicketLisAllDataState: any) {
    const getSupCodeone = []
    getSurpriseTicketLisAllDataState.forEach(res => {
        if (res.range_type == 1 || (res.product_info.product_id === id)) {
            const getresconter = JSON.parse(JSON.stringify(res))
            getresconter.coutcontentinfos = setCoutContentInfo(getresconter)
            getSupCodeone.push(getresconter)
        }
    })
    return getSupCodeone
    function setCoutContentInfo(data) {
        const infoscontent = {
            userconter: data.crowd_info.crowd_name,
            goodrange: data.range_type === 1 ? '全店' : '商品',
            applied_amount: data.applied_amount,
            total_amount: data.total_amount,
            couponname: (() => {
                if (data.coupon_sub_type === 1) {
                    let outerin: any = 0
                    if (data.credit) {
                        outerin = parseFloat((data.credit / 100).toFixed(2))
                    } else {
                        outerin = (() => {
                            if (data.dynamic_coupon_info.avg_dynamic_discount === data.dynamic_coupon_info.max_dynamic_discount) {
                                return parseFloat((data.dynamic_coupon_info.avg_dynamic_discount / 100).toFixed(2))
                            }
                            return `${parseFloat((data.dynamic_coupon_info.avg_dynamic_discount / 100).toFixed(2))} ~ ${parseFloat((data.dynamic_coupon_info.max_dynamic_discount / 100).toFixed(2))}`
                        })()
                    }
                    return `满${parseFloat((data.threshold / 100).toFixed(2))}减${outerin}`
                }
                if (data.coupon_sub_type === 2) {
                    let outerin: any = 0
                    if (data.credit) {
                        outerin = parseFloat((data.credit / 100).toFixed(2))
                    } else {
                        outerin = (() => {
                            if (data.dynamic_coupon_info.avg_dynamic_discount === data.dynamic_coupon_info.max_dynamic_discount) {
                                return parseFloat((data.dynamic_coupon_info.avg_dynamic_discount / 100).toFixed(2))
                            }
                            return `${parseFloat((data.dynamic_coupon_info.avg_dynamic_discount / 100).toFixed(2))} ~ ${parseFloat((data.dynamic_coupon_info.max_dynamic_discount / 100).toFixed(2))}`
                        })()
                    }
                    return `立减${outerin}`
                }
                if (data.coupon_sub_type === 3) {
                    return `${parseFloat((data.discount / 10).toFixed(1))}折`
                }
            })()//+ ` ${data.applied_amount}/${data.total_amount}`
        }
        return infoscontent
    }
}

/**
 * 
 * @param id 
 * @param getCouponListAllDataState 
 * @returns 赛选优惠券
 */
export function getCouponDataFarmet(id: number, getCouponListAllDataState: any) {
    // console.log('开始筛选优惠券', id)
    const getSupCodeone = []
    const isAlterDter = getCouponListAllDataState.filter(item => {
        return item.isallgoods || item.product_id === id
    })
    // console.log('isAlterDter', isAlterDter)
    // console.log('开始前', getSupCodeone)
    isAlterDter.forEach(res => {
        // console.log('res123456', res)
        // if (res.isallgoods || res.product_id === id) {
        const getAllconterJson = JSON.parse(JSON.stringify(res))
        // console.log('getAllconterJson', getAllconterJson)
        getAllconterJson.coutcontentinfos = setCoutContentInfo(getAllconterJson)
        // console.log('getAllconterJson222', getAllconterJson)

        getSupCodeone.push(getAllconterJson)
        // }
    })
    return getSupCodeone
    function setCoutContentInfo(data) {
        if (data.couponData?.coupon_source === 1) {
            const infoscontent = {
                userconter: (() => {
                    switch (data.couponData.support_type) {
                        case 2:
                            return '全网推广-涨粉'

                        case 4:
                            return '全网推广-店铺新人'

                        case 11:
                            return '全网推广-达人专属'

                        case 1:
                            return '全网推广-通用'
                        case 5:
                            return '全网推广-通用'
                        case 6:
                            return '客服-通用'

                        default:
                            break;
                    }
                })(),
                goodrange: data.isallgoods ? '全店' : '商品',
                couponname: (() => {
                    //优惠方式==》 0：全部 21：全店通用-折扣 22：全店通用-立减 23：全店通用-满减 41：指定商品-折扣 42：指定商品-立减 43：指定商品-满减
                    const setdater = data.isallgoods ? data.couponData.favoured_type - 20 : data.couponData.favoured_type - 40
                    if (setdater === 1) {
                        const discount = parseFloat((data.couponData.discount / 10).toFixed(2))
                        return `打${discount}折`
                    }
                    if (setdater === 2) {
                        return `立减${parseFloat((data.couponData.credit / 100).toFixed(2))}元`
                    }
                    if (setdater === 3) {
                        const threshold = data.couponData.threshold / 100
                        return `满${parseFloat(threshold.toFixed(2))}减${parseFloat((data.couponData.credit / 100).toFixed(2))}`

                    }
                })(),
                total_amount: data.couponData.total_amount,
                applied_amount: data.couponData.total_amount - data.couponData.left_amount,
            }
            return infoscontent
        }
        return false
    }
}

/**
 * 
 * @param pra 
 * @returns 获取拼团商品
 */
export function getPromotionListFlashFarmet(pra: { page: number, pageSize: number }) {
    let GoodsDataCache = []
    let goodsResolve: any = null
    return getFlashWithGoodsData(pra)
    function getFlashWithGoodsData(data: any) {
        return new Promise((resolve, reject) => {
            goodsResolve = goodsResolve || resolve
            getPromotionListFlash(data).then((res: any) => {
                const getDetailData = res?.total > 0 && res.data
                    .map((item: any) => {
                        return getPromotionDetails({ campaign_id: item.campaign_id })
                    }) || goodsResolve([])
                getDetailData && getDetailData.length && Promise.all(getDetailData).then(goodsitem => {
                    // 过滤去重
                    GoodsDataCache.push(...goodsitem.map(item => item.data))
                    if (res?.total > (data.page * data.pageSize)) {
                        data.page++
                        getFlashWithGoodsData(data)
                    } else {
                        const manjianActivityData = []
                        GoodsDataCache.forEach(ptld => {
                            ptld.promotion_goods.forEach(ptgod => {
                                for (let key in ptld) {
                                    if (key !== 'promotion_goods') {
                                        ptgod[key] = ptld[key]

                                    }
                                }
                                manjianActivityData.push(ptgod)
                            })
                        })
                        goodsResolve(manjianActivityData)
                    }
                })
            }).catch(err => {
                console.log(err)
            })
        })
    }
}

export function getpromotionListFlashItemFarmet(id: string, getPromotionListFlashAllDataState: any) {
    const getFindInfoter = getPromotionListFlashAllDataState.find(item => item.product_id === id)
    if (!getFindInfoter) {
        return {
            showstatus: false,
        }
    }
    const getFindInfoterJSON = JSON.parse(JSON.stringify(getFindInfoter))

    const minp = Math.min(...getFindInfoterJSON.promotion_skus.map(item => item.price))
    const maxp = Math.max(...getFindInfoterJSON.promotion_skus.map(item => item.price))
    const mino = Math.min(...getFindInfoterJSON.promotion_skus.map(item => item.origin_price))
    const maxo = Math.max(...getFindInfoterJSON.promotion_skus.map(item => item.origin_price))
    getFindInfoterJSON.min_price = minp
    getFindInfoterJSON.max_price = maxp
    getFindInfoterJSON.minPrice = minp
    getFindInfoterJSON.nowPrice = minp == maxp ? `￥${(maxp / 100).toFixed(2)}` : `￥${(minp / 100).toFixed(2)}~￥${(maxp / 100).toFixed(2)}`
    getFindInfoterJSON.showstatus = true
    // getFindInfoterJSON.getFindInfoter = getFindInfoterJSON
    getFindInfoterJSON.tagname = '拼团'
    getFindInfoterJSON.originalPrice = mino === maxo ? `￥${(maxo / 100).toFixed(2) * 1}` : `￥${(mino / 100).toFixed(2) * 1}~￥${(maxo / 100).toFixed(2) * 1}`

    return getFindInfoterJSON
}

export function getDiscountActivityOnnPrdFarmet(id: string, getPromotionListFlashAllDataState: any) {
    const getFindInfoter = getPromotionListFlashAllDataState.find(item => item.product_id === id)
    if (!getFindInfoter) {
        return {
            showstatus: false,
        }
    }
    const getFindInfoterData = JSON.parse(JSON.stringify(getFindInfoter))
    getFindInfoterData.showstatus = true
    getFindInfoterData.discount_type_string = []
    getFindInfoterData.discounts.forEach((res: any) => {
        getFindInfoterData.discount_type_string.push(setTypeString(res))
    })
    return getFindInfoterData
    function setTypeString(data: any) {
        const { activity_type } = getFindInfoterData
        const { discount_type, condition_type, condition_value, discount } = data
        if (activity_type === 1) {
            return {
                title: `第二件半价`,
                func: '*',
                out_type: 'jian',
                condition_value,
                discount: (discount / 10).toFixed(1),
                condition_type,
                discount_type,
                condition_value_ol: condition_value,
                discount_ol: discount,
                activity_type
            }
        }
        if (activity_type === 2) {
            return {
                title: `第二件 0 元`,
                func: '*',
                out_type: 'jian',
                condition_value,
                discount: (discount / 10).toFixed(1),
                condition_type,
                discount_type,
                condition_value_ol: condition_value,
                discount_ol: discount,
                activity_type
            }
        }
        if (activity_type === 3) {
            if (discount_type === 1) {
                return {
                    title: `第${condition_value}件${(discount / 10).toFixed(1) * 1}折`,
                    func: '*',
                    out_type: 'jian',
                    condition_value,
                    discount: (discount / 10).toFixed(1),
                    condition_type,
                    discount_type,
                    condition_value_ol: condition_value,
                    discount_ol: discount,
                    activity_type
                }
            } else if (discount_type === 3) {
                return {
                    title: `第${condition_value}件减${(discount / 100).toFixed(2) * 1}`,
                    func: '-',
                    out_type: 'jian',
                    condition_value,
                    discount: (discount / 100).toFixed(2),
                    condition_type,
                    discount_type,
                    condition_value_ol: condition_value,
                    discount_ol: discount,
                    activity_type
                }
            }
            return
        }

        // if (condition_type === 1) {
        //     if (discount_type === 1) {
        //         return {
        //             title: `满${condition_value}件${(discount / 10).toFixed(1) * 1}折`,
        //             func: '*',
        //             out_type: 'jian',
        //             condition_value,
        //             discount: (discount / 10).toFixed(1),
        //             condition_type,
        //             discount_type,
        //             condition_value_ol: condition_value,
        //             discount_ol: discount
        //         }
        //     } else if (discount_type === 3) {
        //         return {
        //             title: `满${condition_value}件减${(discount / 100).toFixed(2) * 1}`,
        //             func: '-',
        //             out_type: 'jian',
        //             condition_value,
        //             discount: (discount / 100).toFixed(2),
        //             condition_type,
        //             discount_type,
        //             condition_value_ol: condition_value,
        //             discount_ol: discount
        //         }
        //     }
        // } else if (condition_type === 2) {
        //     if (discount_type === 1) {
        //         return {
        //             title: `满${(condition_value / 100).toFixed(2) * 1}元${(discount / 10).toFixed(1) * 1}折`,
        //             func: '*',
        //             out_type: 'yuan',
        //             condition_value: (condition_value / 100).toFixed(2),
        //             discount: (discount / 10).toFixed(1),
        //             condition_type,
        //             discount_type,
        //             condition_value_ol: condition_value,
        //             discount_ol: discount
        //         }
        //     } else if (discount_type === 3) {
        //         return {
        //             title: `满${(condition_value / 100).toFixed(2) * 1}减${(discount / 100).toFixed(2) * 1}`,
        //             func: '-',
        //             out_type: 'yuan',
        //             condition_value: (condition_value / 100).toFixed(2),
        //             discount: (discount / 100).toFixed(2),
        //             condition_type,
        //             discount_type,
        //             condition_value_ol: condition_value,
        //             discount_ol: discount
        //         }
        //     }
        // }
    }

    // return getFindInfoterJSON
}